{include file="index/header" /}
<style type="text/css">
	.inputs{display: inline-block;border: solid 1px #ddd;border-radius: 4px;margin: 0 2px;width: 58px;height: 36px;}
</style>
<body>
	<div class="panel admin-panel">
		<form method="post" action="{:url('document')}" id="listform">
			<div class="panel-head"><strong class="icon-reorder"> 内容列表</strong></div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left:10px;">
					<li><a href="javascript:void(0)" class="button border-main" onclick="documents()" > 导出表格</a></li>
					<li>
						<select name="action" class="input" style="width:150px; line-height:17px;" onchange="changesearch()">
							<option value="">请选择注册方式</option>
							<option value="1"  {if  $param.action eq 1} selected {/if}>PC端</option>
							<option value="2"  {if  $param.action eq 2} selected {/if}>手机端</option>
							<option value="3"  {if  $param.action eq 3} selected {/if}>小程序端</option>
						</select>
					</li>
					<li>
						<input type="search" placeholder="手机号/邮箱" name="phone" value="{$param.phone}" class="input"  style="width:250px; line-height:17px;display:inline-block;"/>
					</li>
					<a href="javascript:void(0)" class="button border-main" onclick="changesearch()">搜索用户</a>
					<a href="?order=record" class="button">观看时长排序</a>
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr>
					<th>序号</th>
					<th>昵称</th>
					<th>手机号</th>
					<th>会员身份</th>
					<th>有效期</th>
					<th>观看时长</th>
					<th>注册时间</th>
					<th>注册来源</th>
					<th>备注</th>
					{if $admin.role_id eq 1}<th>操作</th>{/if}
				</tr>
				{foreach $user_data as $k=>$v}
				<tr>
					<td><input type="checkbox" name="user_id[]" value="{$v.know_user_id}" />{$k+1}</td>
					<td>{$v.know_nickname}</td>
					<td>{$v.know_phone ?: $v.know_email}</td>
					<td>{$v.know_user_id|returnUserDispose=###}</td>
					<td>{$v.know_user_id|returnUserExpireDispose=###}</td>
					<td>{$v.records|Sec2Time=###}</td>
					<td>{$v.register_time}</td>
					<td>{if $v.action eq 0}PC{elseif $v.action eq 1}手机{else}小程序{/if}</td>
					<td  align="left" style="cursor:pointer;"><span class='remark' data-id={$v.know_user_id}>{if $v.know_remark}{$v.know_remark}{else}<font color="#ddd">点击修改</font>{/if}</span></td>
					{if $admin_id eq 1}
					<td>
						<div class="button-group">
							<a class="button border-main" href="{:url('nav_price',['id' => $v['know_user_id'],'page'=>$page,'phone'=>$param['phone'],'start_time'=>$param['start_time'],'end_time'=>$param['end_time']])}"><span class="icon-edit"></span>设置用户身份</a>
							<a class="button border-main" href="{:url('detail',['id' => $v['know_user_id']])}">查看详情</a>
							<a class="button border-main" href="/progress.html?userid={$v.know_user_id}&preview=true" target="_blank">学习进度</a>
							<a class="button border-red" href="{:url('locking',['id' => $v['know_user_id'],'page'=>$page,'phone'=>$param['phone'],'start_time'=>$param['start_time'],'end_time'=>$param['end_time']])}"  onclick="if(confirm('确定操作?')==false)return false;"><span class="icon-trash-o"></span> {if $v.locking eq 1}去锁定（休学）{else}去解锁（停止休学）{/if}</a>
						</div>
				</td>
					{/if}
				</tr>
				{/foreach}
				<tr>
					<td colspan="10" align="left"><input type="checkbox" id="checkall"/>
					全选 </td>
				</tr>
				<tr><td colspan="10">{$user_data->render()}<input type="number" name="page" class="inputs input_page" placeholder="页码"><input type="button" value="跳转" class="inputs input_button"></td></tr>
			</table>
		</form>
	</div>
</body></html>
<script>
	//搜索
	function documents(){  
		$("#listform").submit();
	}
	function changesearch(){
		$("#listform").attr('action','/atxunda/user/index');    //通过jquery为action属性赋值
		$("#listform").submit();   //提交ID为myform的表单
	}
	//全选
	$("#checkall").click(function(){ 
		$("input[name='user_id[]']").each(function(){
			if (this.checked) {
				this.checked = false;
			}
			else {
				this.checked = true;
			}
		});
	});
	$('.input_button').click(function(){
		var page = $('.input_page').val();
		if(!page){
			layer.msg('请输入页码',function(){})
		}else{
			window.location.href='/atxunda/user/index?page='+page;
		}
	});
	$(document).on('click','.remark',function(){
		var content = $(this).text();
		if(content == '点击修改') content = '';
		$(this).parent().html('<textarea placeholder="备注" name="remark" value="'+content+'" class="input fo" style="width:200px;height:50px" data-id="'+$(this).data('id')+'">'+content+'</textarea>');
	});
	$(document).on('blur','.fo',function(){
		var _ts = $(this);
		$.ajax({
			data:{id:_ts.data('id'),remarks:_ts.val()},
			url:"/atxunda/user/changeremark",
			type:'post',
			success:function(obj){
				var content = _ts.val();
				if (content == '' ) content = '<font color="#ddd">点击修改</font>';
				_ts.parent().html('<span class="remark" data-id="'+_ts.data('id')+'">'+content+'</span>');
			}
		})
	});
</script>